//
//  HJProfileHeaderView.m
//  project
//
//  Created by jc on 2019/5/10.
//  Copyright © 2019 健健. All rights reserved.
//

#import "HJProfileHeaderView.h"
#import "YFJourneyModel.h"
#import "YFJourneyTagView.h"


@interface HJProfileHeaderView ()
@property (weak, nonatomic) IBOutlet UIView *bgView;
@property (weak, nonatomic) IBOutlet UILabel *signature;
@property (weak, nonatomic) IBOutlet UIButton *chatBtn;

@property (weak, nonatomic) IBOutlet UIView *tagsView;
@property (nonatomic,strong) YFUserModel * model;
@end
@implementation HJProfileHeaderView

+(instancetype)profileHeader {
    HJProfileHeaderView * profieHeader = [[HJProfileHeaderView alloc]init];
    return profieHeader;
}

-(instancetype)init {
    if (self ==[super init]) {
        self = [[NSBundle mainBundle]loadNibNamed:@"HJProfileHeaderView" owner:nil options:nil].firstObject;
        [self initSubView];
    }
    return self;
}
-(void)initSubView {
//    [self setupShadowWithView:self.bgView];
    [self.chatBtn rounded:UIRectCornerAllCorners radius:40];
    @weakify(self)
    [[self.chatBtn rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(__kindof UIControl * _Nullable x) {
        @strongify(self)
        self.block(self.model);
    }];
}

-(void)setUserModel:(YFUserModel *)userModel {
    self.model = userModel;
    self.signature.text = [NSString stringWithFormat:@"个性签名：%@",userModel.intro.length ==0? @"" :userModel.intro];
    // 设置 Tag
    YFJourneyTagView *tags = [[YFJourneyTagView alloc] initWithFrame:self.tagsView.bounds tags:userModel.tagArray sameColor:UIColor.blackColor];
    [self.tagsView addSubview:tags];
}

@end
